﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
    <!-- Resource dictionary entries should be defined here. -->
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Colors.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type TabItem}">
        <Setter Property="Foreground">
            <Setter.Value>
                <SolidColorBrush Color="{StaticResource Application_Control_Foreground}"/>
            </Setter.Value>
        </Setter>
		<Setter Property="Height" Value="20"/>
		<Setter Property="VerticalContentAlignment" Value="Center"/>
		<Setter Property="HorizontalContentAlignment" Value="Center"/>
		<Setter Property="Template" Value="{DynamicResource TabItemTemplate}"/>
	</Style>

    <ControlTemplate x:Key="TabItemTemplate" TargetType="{x:Type TabItem}">
    	<Grid Width="{TemplateBinding Width}" Height="22">
    		<Grid.ColumnDefinitions>
    			<ColumnDefinition Width="*"/>
    			<ColumnDefinition Width="22"/>
    		</Grid.ColumnDefinitions>
    		<VisualStateManager.VisualStateGroups>
    			<VisualStateGroup x:Name="CommonStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition From="MouseOver" GeneratedDuration="0:0:0.4" To="Normal"/>
    					<VisualTransition From="Normal" GeneratedDuration="0:0:0.4" To="MouseOver"/>
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="Normal"/>
    				<VisualState x:Name="MouseOver">
    					<Storyboard>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="path">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_TabItem_Background_Move}"/>
    						</ColorAnimationUsingKeyFrames>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_TabItem_Background_Move}"/>
    						</ColorAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    				<VisualState x:Name="Disabled">
    					<Storyboard>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_TextBox_Foreground_Disabled}"/>
    						</ColorAnimationUsingKeyFrames>
    					</Storyboard>
					</VisualState>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="SelectionStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition From="Unselected" GeneratedDuration="0:0:0.2" To="Selected"/>
    					<VisualTransition From="Selected" GeneratedDuration="0:0:0.2" To="Unselected"/>
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="Unselected"/>
    				<VisualState x:Name="Selected">
    					<Storyboard>
    						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="borderSelection">
    							<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
    						</DoubleAnimationUsingKeyFrames>
    						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="pathSelection">
    							<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
    						</DoubleAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    		</VisualStateManager.VisualStateGroups>
    		<Border x:Name="border" 
    			Padding="{TemplateBinding Padding}" CornerRadius="5,5,0,0">
    			<Border.Background>
    				<SolidColorBrush Color="{StaticResource Application_TabItem_Background}"/>
    			</Border.Background>
    		</Border>
			<Path x:Name="path" Grid.Column="1" Data="M0,0 L0,25 25,25" Height="Auto" Stretch="Fill" VerticalAlignment="Stretch" Margin="-2,1,0,0">
				<Path.Fill>
					<SolidColorBrush Color="{StaticResource Application_TabItem_Background}"/>
				</Path.Fill>
			</Path>
    		<Border x:Name="borderSelection" 
    			Padding="{TemplateBinding Padding}" CornerRadius="5,5,0,0" Visibility="Visible" Opacity="0">
    			<Border.Background>
    				<SolidColorBrush Color="{StaticResource Application_TabItem_Background_Selection}"/>
    			</Border.Background>
    		</Border>
			<Path x:Name="pathSelection" Grid.Column="1" Data="M0,0 L0,5 5,5" Height="Auto" Stretch="Fill" VerticalAlignment="Stretch" Margin="-2,1,0,0" Visibility="Visible" Opacity="0">
				<Path.Fill>
					<SolidColorBrush Color="{StaticResource Application_TabItem_Background_Selection}"/>
				</Path.Fill>
			</Path>
			<ContentPresenter ContentSource="Header" 
				HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
				VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="8,1,1,1"/>
    	</Grid>
    </ControlTemplate>
</ResourceDictionary>